extends "../lafei-2/lafei-2.gd"


func _extInit():
	._extInit()
	lv = 3             #等级的设置
	addSkill("本回合阵亡1个非召唤友军时启动：冷却速度+100%，击杀敌人后立即向血量最低的2名敌人发射鱼雷", "所罗门战神")

var flag = 0
func _onCharaDel(cha):
	._onCharaDel(cha)
	if cha.isSumm or cha.team != team:return
	flag += 1
	if flag == 1:
		utils.createSkillTextEff("所罗门战神", position)
		addBuff(b_laffey.new())
		if lv == 4:
			buff.addShengDun(self, 10)
			addBuff(buff.b_zhenFen.new(10))
			tujin()

func tujin():
	var chas = getAllChas(1)
	chas.sort_custom(sys, "sortByMaxHp")
	for cha in chas:
		if cha.isDeath || cha.isSumm:continue
		var mv = Vector2(cha.cell.x ,cha.cell.y)
		for i in config.aroundCells:
			var v = mv+i
			if matCha(v) == null && sys.main.isMatin(v) and setCell(v):
				var pos = sys.main.map.map_to_world(cell)
				ying(pos)
				position = pos
				aiCha = cha
				azurHurtChara(cha, cha.att.maxHp*3, sys.HurtType.REAL, sys.AtkType.EFF, "所罗门战神")
				addBuff(buff.b_moHu.new(10))
				return

func _onBattleEnd():
	._onBattleEnd()
	flag = 0

class b_laffey:
	extends "../../../../azurlane_ctrl/AzurBuff.gd"
	var flag = true
	func _init():
		attInit()
		id = "b_laffey2"	
		att.cd = 1
		buffName = "所罗门战神"
		dispel = 2
	func _connect():
		._connect()
		masCha.connect("onKillChara", self, "run")
	func _upS():
		flag = true
	func run(atkInfo):
		if not flag:return
		flag = false
		var chas = masCha.getAllChas(1)
		chas.sort_custom(sys, "sortByHp")
		for i in range(2):
			if i >= chas.size():break
			masCha.castTorpedo(chas[i])